from Products.KnowledgeEngine.KERL.Tokens.Token import Token
from Products.KnowledgeEngine.Services.MySQLFiveAssessmentStorageService.MySQLFiveAssessmentStorageService import qstr

class NumericToken(Token):
    
    def __init__(self, object, namespace):
        if type(object) not in (int, float):
            raise "Creating NumericToken with non-numeric value %s" % `object`
        
        Token.__init__( self, object, namespace )
    
    def toEnglish(self):
        """ Compiles this token into english """
        
        return str(self.object)

    def toSQL(self, quote="'"):
        """ Compiles this token into SQL """
        
        return str(self.object)

    def toJavascript(self):
        
        return str(self.getObject())

    def toKERL(self):
        return str(self.getObject())


    def __str__(self):
        return str(self.getObject()) 